CC = gcc
CFLAGS = -O2 -Wall
#CFLAGS = -g -Wall
INSTALL_PREFIX = $(HOME)

PROGS = compute_mtf_dc invert_mtf byte_to_int32 mint32_to_ascii

.PHONY: all install clean uninstall
all: $(PROGS)

%.o: %.c %.h

%:
	$(CC) -o $@ $+

byte_to_int32: byte_to_int32.o map_file.o

mint32_to_ascii: mint32_to_ascii.o

compute_mtf_dc: compute_mtf_dc.o mergesort_inversion_vector.o map_file.o

invert_mtf: invert_mtf.o mergesort_inversion_vector.o map_file.o

install: compute_mtf_dc invert_mtf
	test -d $(INSTALL_PREFIX)/bin && cp compute_mtf_dc invert_mtf $(INSTALL_PREFIX)/bin

uninstall:
	$(RM) $(INSTALL_PREFIX)/bin/compute_mtf_dc $(INSTALL_PREFIX)/bin/invert_mtf

clean:
	$(RM) *.o $(PROGS)
